<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
</html>
<script>
//  完善函数 实现img加载 
// function createImg(url) {
//     createImg(url).then((value)=>{
//         document.body.appendChild(value);  
//     })
// }


// 方式一 
function createImg(url) {
    return new Promise((res,rej)=>{
        if(url){
            let imgUrl = document.createElement("img");
            imgUrl.src = url;
            res(imgUrl)
        }else{
            return "err img ..."
        }
    })
}

createImg('XXX').then((value)=>{
    console.log(value);
    document.body.appendChild(value)
})















</script>